<?php

namespace app\admin\model;

use think\Model;


class Order extends Model
{

    
    const STATUS = [
        0=>"待揽件",
        1=>"待配送",
        2=>"配送成功",
        9=>"配送失败"
    ];
    

    // 表名
    protected $name = 'order';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];
    

    //获取订单号
    public static function getOrderSn(){
        $model = new self();
        $letter = "TM";
        $start_number = "2100001";
        $info = $model->field(["orderSn,id"])->order("orderSn desc")->find();
        if(empty($info)){
            return $letter.$start_number;
        }
        $number = substr($info['orderSn'],2);
        $number +=1;
        return $letter.$number;
    }







}
